using ASP;
using HoWave.Web;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.UI.WebControls;
public class Shop_UserControls_ShowArticle : Howave_ControlCache
{
	protected Literal ShopArticleLiteral;
	private int m_num = 10;
	private string m_showType = "text";
	private string m_showFlag = "none";
	private int m_titleLength = 0;
	private string m_styleName = "";
	private string m_classID = "-1";
	private string m_openType = "_self";
	private string m_showField = "";
	private int m_sortType = -1;
	private int m_rowNum = 1;
	private string m_othertype = "";
	private string m_fronticon = "";
	private string m_moduleID = "-1";
	private string m_dateStart = "";
	private string m_dateEnd = "";
	private int m_linktype = -1;
	private string m_titleType = "short";
	private string m_autoUpdate = "false";
	private int m_updateCacheTime = 1;
	private bool m_summary = false;
	private string m_summaryset = string.Empty;
	private string m_labelName;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	public string LabelName
	{
		get
		{
			return this.m_labelName;
		}
		set
		{
			this.m_labelName = value;
		}
	}
	public string Summary
	{
		set
		{
			this.m_summaryset = value;
		}
	}
	public string AutoUpdate
	{
		get
		{
			return this.m_autoUpdate;
		}
		set
		{
			this.m_autoUpdate = value;
		}
	}
	public int CacheTime
	{
		get
		{
			return this.m_updateCacheTime;
		}
		set
		{
			this.m_updateCacheTime = value;
		}
	}
	public int ShowNum
	{
		get
		{
			return this.m_num;
		}
		set
		{
			this.m_num = value;
		}
	}
	public string ShowUIType
	{
		get
		{
			return this.m_showType;
		}
		set
		{
			this.m_showType = value;
		}
	}
	public string ArticleDateStart
	{
		get
		{
			return this.m_dateStart;
		}
		set
		{
			this.m_dateStart = value;
		}
	}
	public string ArticleTitleType
	{
		get
		{
			return this.m_titleType;
		}
		set
		{
			this.m_titleType = value;
		}
	}
	public string ArticleDateEnd
	{
		get
		{
			return this.m_dateEnd;
		}
		set
		{
			this.m_dateEnd = value;
		}
	}
	public string ShowFlag
	{
		get
		{
			return this.m_showFlag;
		}
		set
		{
			this.m_showFlag = value;
		}
	}
	public int LinkType
	{
		get
		{
			return this.m_linktype;
		}
		set
		{
			this.m_linktype = value;
		}
	}
	public string StyleName
	{
		get
		{
			return this.m_styleName;
		}
		set
		{
			this.m_styleName = value;
		}
	}
	public string ArticleType
	{
		get
		{
			return this.m_moduleID;
		}
		set
		{
			this.m_moduleID = value;
		}
	}
	public string ClassID
	{
		get
		{
			return this.m_classID;
		}
		set
		{
			this.m_classID = value;
		}
	}
	public int RowNums
	{
		get
		{
			return this.m_rowNum;
		}
		set
		{
			this.m_rowNum = value;
		}
	}
	public int SortType
	{
		get
		{
			return this.m_sortType;
		}
		set
		{
			this.m_sortType = value;
		}
	}
	public string OpenType
	{
		get
		{
			return this.m_openType;
		}
		set
		{
			this.m_openType = value;
		}
	}
	public string OtherType
	{
		get
		{
			return this.m_othertype;
		}
		set
		{
			this.m_othertype = value;
		}
	}
	public int TitleLength
	{
		get
		{
			return this.m_titleLength;
		}
		set
		{
			this.m_titleLength = value;
		}
	}
	public string ShowField
	{
		get
		{
			return this.m_showField;
		}
		set
		{
			this.m_showField = value;
		}
	}
	public string FrontIcon
	{
		get
		{
			return this.m_fronticon;
		}
		set
		{
			this.m_fronticon = value;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		base.ControlID = this.ID;
		base.ControlAutoUpdate = this.m_autoUpdate;
		base.UpdateCacheTime = this.m_updateCacheTime;
		string str = base.GetStr();
		if (!string.IsNullOrEmpty(str) && str != "")
		{
			this.ShopArticleLiteral.Text = str.Replace("<![CDATA[", "").Replace("]]>", "");
		}
	}
	public override string GetStrFromControl()
	{
		if (this.m_classID != "")
		{
			int num = int.Parse(this.m_classID);
		}
		int num2 = 0;
		int num3 = 300;
		if (this.m_summaryset != "" && this.m_summaryset.Contains("|"))
		{
			try
			{
				string[] array = this.m_summaryset.Split(new char[]
				{
					'|'
				});
				num2 = int.Parse(array[0]);
				num3 = int.Parse(array[1]);
				this.m_summary = true;
			}
			catch
			{
				this.m_summary = false;
			}
		}
		Shop_Article shop_Article = new Shop_Article();
		DataTable dataTable = shop_Article.SearchArticle(this.m_num, 0, this.m_moduleID, this.m_classID, this.m_dateStart, this.m_dateEnd, this.m_sortType, this.m_othertype, this.m_showType, "", this.m_linktype, this.m_summary);
		string result;
		if (dataTable != null && dataTable.Rows.Count > 0)
		{
			if (dataTable.Rows.Count < this.m_num)
			{
				this.m_num = dataTable.Rows.Count;
			}
			string text = "/";
			if (this.m_styleName != "" && this.m_styleName != null)
			{
				this.m_styleName = "class=\"" + this.m_styleName + "\"";
			}
			string text2 = string.Concat(new string[]
			{
				"<!--缓存时间：",
				DateTime.Now.ToString(),
				"--><ul ",
				this.m_styleName,
				">",
				Environment.NewLine
			});
			string text3 = "";
			if (this.m_showFlag != "none")
			{
				string text4 = this.m_showFlag;
				if (text4 != null)
				{
					if (!(text4 == "hot-icon"))
					{
						if (text4 == "new-icon")
						{
							text3 = "<img src=\"" + text + "/Images/new-icon.gif\" border=\"0\"/>";
						}
					}
					else
					{
						text3 = "<img src=\"" + text + "/Images/hot-icon.gif\" border=\"0\"/>";
					}
				}
			}
			for (int i = 0; i < this.m_num; i++)
			{
				string text5 = "";
				if (this.m_showField != "")
				{
					string[] array2 = this.m_showField.Split(new char[]
					{
						'|'
					});
					string[] array3 = array2;
					for (int j = 0; j < array3.Length; j++)
					{
						string text6 = array3[j];
						string text7 = text5;
						text5 = string.Concat(new string[]
						{
							text7,
							"<span class=\"span_",
							text6,
							"\">",
							dataTable.Rows[i][text6].ToString(),
							"</span>"
						});
					}
				}
				string text8;
				if (this.m_titleType == "short")
				{
					text8 = dataTable.Rows[i]["ShortTitle"].ToString();
				}
				else
				{
					text8 = dataTable.Rows[i]["LongTitle"].ToString();
				}
				if (this.m_titleLength > 0)
				{
					if (text8.Length > this.m_titleLength)
					{
						text8 = text8.Substring(0, this.m_titleLength);
					}
				}
				string text9 = dataTable.Rows[i]["UploadPicUrl"].ToString();
				if (text9 == null | text9 == "")
				{
					text9 = "/Images/nopicture.gif";
				}
				string text10;
				if (dataTable.Rows[i]["LinkType"].ToString() == "1")
				{
					text10 = dataTable.Rows[i]["LinkUrl"].ToString();
				}
				else
				{
					text10 = text + "ShowArticle.aspx?id=" + dataTable.Rows[i]["ArticleID"].ToString();
				}
				if (dataTable.Rows[i]["IsHighDisplay"].ToString() == "1")
				{
					text8 = "<span color:red>" + text8 + "</span>";
				}
				string text11 = string.Empty;
				string text12 = string.Concat(new string[]
				{
					"<a href=\"",
					text10,
					"\" target=\"",
					this.m_openType,
					"\" title=\"",
					dataTable.Rows[i]["ShortTitle"].ToString(),
					"\">"
				});
				if (this.m_summary && dataTable.Rows[i]["summary"].ToString().Length > 1 && i <= num2)
				{
					string text13 = dataTable.Rows[i]["summary"].ToString();
					if (text13.Length > num3)
					{
						text13 = "&nbsp;&nbsp;" + text13.Substring(0, num3);
					}
					text11 = string.Concat(new string[]
					{
						"<span class=\"summary_title\">",
						text12,
						text8,
						"</a></span><span class=\"summary_content\">",
						text13,
						"...[",
						text12,
						"全文</a>]</span>"
					});
				}
				else
				{
					text11 = "<span class=\"span_title\">" + text12 + text8 + "</a></span>";
				}
				string text4 = this.m_showType.ToLower();
				if (text4 != null)
				{
					if (!(text4 == "text"))
					{
						if (!(text4 == "img"))
						{
							if (text4 == "imgtext")
							{
								string text7 = text2;
								text2 = string.Concat(new string[]
								{
									text7,
									"<li>",
									text12,
									"<img src=\"",
									text,
									text9,
									"\"title=\"",
									dataTable.Rows[i]["ShortTitle"].ToString(),
									"\"/></a><p><span class=\"span_title\">",
									text12,
									text8,
									"</a></span>",
									text5,
									text3,
									"</p></li>",
									Environment.NewLine
								});
							}
						}
						else
						{
							string text7 = text2;
							text2 = string.Concat(new string[]
							{
								text7,
								"<li>",
								text12,
								"<img src=\"",
								text,
								text9,
								"\" title=\"",
								dataTable.Rows[i]["ShortTitle"].ToString(),
								"\"/></a></li>",
								Environment.NewLine
							});
						}
					}
					else
					{
						if (this.m_fronticon != "" && this.m_summary && i > num2)
						{
							string text7 = text2;
							text2 = string.Concat(new string[]
							{
								text7,
								"<li><img src=\"",
								text,
								"/Images/front_icon/",
								this.m_fronticon,
								"\" />&nbsp;<span class=\"span_title\">",
								text12,
								text8,
								"</a></span>",
								text5,
								text3,
								"</li>",
								Environment.NewLine
							});
						}
						else
						{
							string text7 = text2;
							text2 = string.Concat(new string[]
							{
								text7,
								"<li>",
								text11,
								text5,
								text3,
								"</li>",
								Environment.NewLine
							});
						}
					}
				}
			}
			dataTable.Dispose();
			text2 = text2 + "</ul>" + Environment.NewLine;
			result = text2;
		}
		else
		{
			result = "暂无文章";
		}
		return result;
	}
}
